package com.ganbo.rabbitmq.basic;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BasicRabbitConfig {

    //交换机
    public final static String EXCHANGE_BASIC_FANOUT = "ganbo.exchange.basic.fanout";

    //队列
    public final static String TOPIC_BASIC1 = "ganbo.topic.basic1";
    public final static String TOPIC_BASIC2 = "ganbo.topic.basic2";
    public final static String TOPIC_BASIC3 = "ganbo.topic.basic3";
    public final static String TOPIC_BASIC4 = "ganbo.topic.basic4";
    public final static String TOPIC_BASIC5 = "ganbo.topic.basic5";
    public final static String TOPIC_BASIC6 = "ganbo.topic.basic6";

    //声明交换机
    @Bean
    public FanoutExchange exchange() {
        return new FanoutExchange(EXCHANGE_BASIC_FANOUT);
    }


    //声明队列
    @Bean
    public Queue queuePay1() {
        return new Queue(BasicRabbitConfig.TOPIC_BASIC1, true);
    }

    @Bean
    public Queue queuePay2() {
        return new Queue(BasicRabbitConfig.TOPIC_BASIC2, true);
    }

    @Bean
    public Queue queuePay3() {
        return new Queue(BasicRabbitConfig.TOPIC_BASIC3, true);
    }
    @Bean
    public Queue queuePay4() {
        return new Queue(BasicRabbitConfig.TOPIC_BASIC4, true);
    }
    @Bean
    public Queue queuePay5() {
        return new Queue(BasicRabbitConfig.TOPIC_BASIC5, true);
    }
    @Bean
    public Queue queuePay6() {
        return new Queue(BasicRabbitConfig.TOPIC_BASIC6, true);
    }

    //绑定队列
    @Bean
    Binding bindingExchangeMessage1() {
        return BindingBuilder.bind(queuePay1()).to(exchange());
    }

    @Bean
    Binding bindingExchangeMessage2() {
        return BindingBuilder.bind(queuePay2()).to(exchange());
    }

    @Bean
    Binding bindingExchangeMessage3() {
        return BindingBuilder.bind(queuePay3()).to(exchange());
    }

    @Bean
    Binding bindingExchangeMessage4() {
        return BindingBuilder.bind(queuePay4()).to(exchange());
    }

    @Bean
    Binding bindingExchangeMessage5() {
        return BindingBuilder.bind(queuePay5()).to(exchange());
    }

    @Bean
    Binding bindingExchangeMessage6() {
        return BindingBuilder.bind(queuePay6()).to(exchange());
    }
}